<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="com.wondersgroup.wssip.workspace.businesscontext.WssipBusinessContextUtils" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <%@include file="/WEB-INF/pages/pub/include.jsp" %>
    <title>企业注册</title>
    <LINK href="<c:url value='/resources/register/css/style.css'/>" type=text/css rel=stylesheet>
    <LINK href="<c:url value='/resources/register/css/nav.css'/>" type=text/css rel=stylesheet>
</head>

<body>
<div class="warp">
    <div class="top">
        <div class="logo">
            <a href="<c:url value="/workspace/logout"/>">
                <img src="<%=request.getContextPath() %>/resources/register/images/logo.png"/>
            </a>
        </div>
    </div>
    <div class="xw-dt">
        <div class="warp-zhuce">
            <div class="w-z-left">
                <ul class="lin-t1">
                    <li class="current" id="lglin_title_0">注册</li>
                </ul>
                <form id="form1" method="post">
                    <div id="lglin_main_0">
                        <div class="zc-text">
                            <p class="zc-p"><font color="red">*</font>机构类型：</p>
                            <div class="sx">
                                <div>
                                    <input style="height:20px;" type="radio" name="bzb028q" value="1" checked>企业</input>
                                    &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; &nbsp;
                                    <input style="height:20px;" type="radio" name="bzb028q" value="2">第三方机构</input>
                                </div>

                                <div>
                                    <input style="height:20px;" type="radio" name="bzb028q" value="3">技工院校</input>&nbsp;	&nbsp;
                                    <input style="height:20px;" type="radio" name="bzb028q" value="4">考项考点</input>
                                </div>
                            </div>
                        </div>

                        <div class="zc-text">
                            <p class="zc-p"><font color="red">*</font>统一社会信用代码：</p>
                            <div class="sx">
                                <input name="bzb021q" id="bzb021q" type="text" class="zz-input" placeholder="请输入统一社会信用代码"/>
                            </div>
                        </div>

                        <p class="zc-ts1">统一社会信用代码作为登录账号，默认密码为账号后6位</p>
                        <div class="zc-text">
                            <p class="zc-p" id="qymc"><font color="red">*</font>企业名称：</p>
                            <div class="sx">
                                <input name="bzb022" id="bzb022" type="text" class="zz-input" placeholder="请输入企业名称"/>
                            </div>
                        </div>
                        <div class="zc-text">
                            <p class="zc-p"><font color="red">*</font>企业性质：</p>
                            <div class="sx">
                                <input id="bzb030q" name="bzb030q" nullItemText="请选择..." class="mini-combobox" emptyText="请选择企业性质" data="${dic['BZB030Q']}" style="width: 353px;  height: 35px;" onvaluechanged="changeLx"/>
                            </div>
                        </div>
                        <div class="zc-text" id="company" style="display:none">
                            <p class="zc-p"><font color="red">*</font>母公司名称：</p>
                            <div class="sx">
                                <input id="bgz120" name="bgz120" class="mini-buttonedit" emptyText="请选择母公司" onclick="onButtonSelect()" allowInput="false" style="width: 353px;  height: 35px;"/>
                            </div>
                        </div>
                        <div class="zc-text"><p class="zc-p"><font color="red">*</font>单位类型：</p>
                            <div class="sx">
                                <input id="bzb029q" name="bzb029q" nullItemText="请选择..." class="mini-combobox" emptyText="请选择单位性质" data="${dic['BZB029Q']}" style=" width: 353px;  height: 35px;"/>
                            </div>
                        </div>
                        <div class="zc-text">
                            <p class="zc-p"><font color="red">*</font>企业所在省：</p>
                            <div class="sx">
                                <input name="bzb032" id="bzb032" type="text" class="zz-input" placeholder="请输入" readonly="true" value="山东省"/>
                            </div>
                        </div>
                        <div class="zc-text">
                            <p class="zc-p"><font color="red">*</font>企业所在市：</p>
                            <div class="sx">
                                <input id="bzb033" name="bzb033" nullItemText="请选择..." class="mini-combobox" emptyText="请选择企业所在市" style=" width: 353px;  height: 45px;"/>
                            </div>
                        </div>
                        <div class="zc-text"><p class="zc-p"><font color="red">*</font>负责人：</p>
                            <div class="sx"><input id="bzb037" name="bzb037" type="text" class="zz-input" placeholder="请输入负责人"/></div>
                        </div>
                        <div class="zc-text"><p class="zc-p"><font color="red">*</font>联系电话：</p>
                            <div class="sx"><input id="bzb039" name="bzb039" type="text" class="zz-input" placeholder="请输入负责人联系电话" onblur="chkTel()"/></div>
                        </div>
                        <div class="zc-text"><p class="zc-p"><font color="red">*</font>电子邮箱：</p>
                            <div class="sx"><input id="bzb041" name="bzb041" type="text" class="zz-input" placeholder="请输入电子邮箱" onblur="checkEmail()"/></div>
                        </div>
                        <div class="zc-text"><p class="zc-p"><font color="red">*</font>企业地址：</p>
                            <div class="sx"><input id="bzb044" name="bzb044" type="text" class="zz-input" placeholder="请输入地址"/></div>
                        </div>
                        <a class="mini-button reg-btn" onclick="onSave()" id="onSave">提交注册</a>
                        <p class="yyzh">已有账号，请<a id="logout" href="<c:url value="/workspace/logout"/>">登录</a></p>
                    </div>
                </form>
            </div>
            <div class="w-z-right">
                <p class="yonghuxuzhi"></p>
                <p class="zhuce-title"><img
                        src="<%=request.getContextPath() %>/resources/register/images/zhucepic-1.png" width="394"
                        height="21" alt=""/></p>
                <div class="zhuce-text">
                    <p class="shuzi"><img src="<%=request.getContextPath() %>/resources/register/images/1.png"
                                          width="26" height="26" alt=""/></p>
                    <p class="xuzhis">遵守中华人民共和国法律法令和其他相关法规，不可发布破坏宪法和法律、法规的信息。</p>
                </div>
                <div class="zhuce-text">
                    <p class="shuzi"><img src="<%=request.getContextPath() %>/resources/register/images/2.png"
                                          width="26" height="26" alt=""/></p>
                    <p class="xuzhis">遵守公安部关于《计算机信息网络国际联网安全保护管理办法》的规定，自觉维护计算机信息网络的安全。</p>
                </div>
                <div class="zhuce-text">
                    <p class="shuzi"><img src="<%=request.getContextPath() %>/resources/register/images/3.png"
                                          width="26" height="26" alt=""/></p>
                    <p class="xuzhis">不得在网上宣扬封建迷信、淫秽、色情、暴力、赌博等不正当行为。 </p>
                </div>
                <div class="zhuce-text">
                    <p class="shuzi"><img src="<%=request.getContextPath() %>/resources/register/images/4.png"
                                          width="26" height="26" alt=""/></p>
                    <p class="xuzhis">企业提交信息要真实有效、准确完整，并不得有引人误解或者虚假的陈述。</p>
                </div>
                <div class="zhuce-text">
                    <p class="shuzi"><img src="<%=request.getContextPath() %>/resources/register/images/5.png"
                                          width="26" height="26" alt=""/></p>
                    <p class="xuzhis">申请人必须填写详细、真实信息，如企业的名称、统一社会信用代码、地址、电话等。因信息填写不真实、不完整或填写错误的本系统将采取注销措施。 </p>
                </div>
                <div class="zhuce-text">
                    <p class="shuzi"><img src="<%=request.getContextPath() %>/resources/register/images/6.png"
                                          width="26" height="26" alt=""/></p>
                    <p class="xuzhis">用户注册成功后，请妥善保管您的用户名和密码，以便下次登录使用。</p>
                </div>
            </div>
        </div>
    </div>
</div>
<div class="clearfix"></div>
<div class="foot">
    <div class="foot-warp">
        <p class="foot-l"><img src="<%=request.getContextPath() %>/resources/register/images/shiye.png"></p>
        <p class="foot-c">山东省职业技能鉴定指导中心主办 联系我们
            <br/>建议电脑屏幕分辨率大于1280×768 使用IE9以上浏览器浏览 未经授权禁止镜像</p>
    </div>
</div>
<script type="text/javascript">
    $(document).ready(function () {
        /* ----- 侧边悬浮 ---- */
        $(document).on("mouseenter", ".suspension .a", function () {
            var _this = $(this);
            var s = $(".suspension");
            var isService = _this.hasClass("a-service");
            var isServicePhone = _this.hasClass("a-service-phone");
            var isQrcode = _this.hasClass("a-qrcode");
            if (isService) {
                s.find(".d-service").show().siblings(".d").hide();
            }
            if (isServicePhone) {
                s.find(".d-service-phone").show().siblings(".d").hide();
            }
            if (isQrcode) {
                s.find(".d-qrcode").show().siblings(".d").hide();
            }
        });
        $(document).on("mouseleave", ".suspension, .suspension .a-top", function () {
            $(".suspension").find(".d").hide();
        });
        $(document).on("mouseenter", ".suspension .a-top", function () {
            $(".suspension").find(".d").hide();
        });
        $(document).on("click", ".suspension .a-top", function () {
            $("html,body").animate({scrollTop: 0});
        });
        $(window).scroll(function () {
            var st = $(document).scrollTop();
            var $top = $(".suspension .a-top");
            if (st > 400) {
                $top.css({display: 'block'});
            } else {
                if ($top.is(":visible")) {
                    $top.hide();
                }
            }
        });

    });

    mini.parse();

    $(function () {
        var checkValue = $('input:radio:checked').val();
        check(checkValue);

    });
    $(':radio').click(function () {
        var checkValue = $(this).val();
        check(checkValue);
    });

    function check(checkValue) {

        if ("1" == checkValue) {
            // 机构性质
            var bzb030q = mini.get("bzb030q");
            bzb030q.setData([{id: 1, text: "央属"}, {id: 2, text: "省属"}, {id: 3, text: "市属"},]);
            var ps = document.getElementsByClassName("zc-p");
            for (var i = 0; i < ps.length; i++) {
                var neirong = ps[i].innerHTML;
                neirong = neirong.replace("机构", "企业");
                neirong = neirong.replace("考点", "企业");
                neirong = neirong.replace("院校", "企业");
                ps[i].innerHTML = neirong;
            }
            var bzb022 = $("#bzb022");
            $(bzb022).attr('placeholder', '请输入企业名称')
            var bzb030q = mini.get("bzb030q");
            bzb030q.setEmptyText("企业性质");
            var bzb033 = mini.get("bzb033");
            bzb033.setEmptyText("企业所在市");

        } else if ("2" == checkValue) {
            // 机构性质
            var bzb030q = mini.get("bzb030q");
            bzb030q.setData([{id: 2, text: "省属"}, {id: 3, text: "市属"},]);
            var ps = document.getElementsByClassName("zc-p");
            for (var i = 0; i < ps.length; i++) {
                var neirong = ps[i].innerHTML;
                neirong = neirong.replace("企业", "机构");
                neirong = neirong.replace("院校", "机构");
                neirong = neirong.replace("考点", "机构");
                ps[i].innerHTML = neirong;
            }
            var bzb022 = $("#bzb022");
            $(bzb022).attr('placeholder', '请输入机构名称')
            var bzb030q = mini.get("bzb030q");
            bzb030q.setEmptyText("机构性质");
            var bzb033 = mini.get("bzb033");
            bzb033.setEmptyText("机构所在市");
        } else if ("3" == checkValue) {
            // 技工院校
            var bzb030q = mini.get("bzb030q");
            bzb030q.setData([{id: 2, text: "省属"}, {id: 3, text: "市属"},]);
            var ps = document.getElementsByClassName("zc-p");
            for (var i = 0; i < ps.length; i++) {
                var neirong = ps[i].innerHTML;
                neirong = neirong.replace("企业", "院校");
                neirong = neirong.replace("机构", "院校");
                neirong = neirong.replace("考点", "院校");
                ps[i].innerHTML = neirong;
            }
            var bzb022 = $("#bzb022");
            $(bzb022).attr('placeholder', '请输入院校名称')
            var bzb030q = mini.get("bzb030q");
            bzb030q.setEmptyText("院校性质");
            var bzb033 = mini.get("bzb033");
            bzb033.setEmptyText("院校所在市");
        } else if ("4" == checkValue) {
            // 考项考点
            var bzb030q = mini.get("bzb030q");
            bzb030q.setData([{id: 2, text: "省属"}, {id: 3, text: "市属"},]);
            var ps = document.getElementsByClassName("zc-p");
            for (var i = 0; i < ps.length; i++) {
                var neirong = ps[i].innerHTML;
                neirong = neirong.replace("企业", "考点");
                neirong = neirong.replace("机构", "考点");
                neirong = neirong.replace("院校", "考点");
                ps[i].innerHTML = neirong;
            }
            var bzb022 = $("#bzb022");
            $(bzb022).attr('placeholder', '请输入考点名称')
            var bzb030q = mini.get("bzb030q");
            bzb030q.setEmptyText("考点性质");
            var bzb033 = mini.get("bzb033");
            bzb033.setEmptyText("考点所在市");
        }

    }

    //  加载山东省城市列表
    var bzb033 = mini.get("bzb033");
    $.ajax({
        url: "<c:url value="/register/queryShanCity"/>",
        type: "get",
        async: false,
        success: function (data) {
            bzb033.setData(data);
        },
        error: function () {
        }
    });
    // 电话校验
    String.prototype.Trim = function () {
        var m = this.match(/^\s*(\S+(\s+\S+)*)\s*$/);
        return (m == null) ? "" : m[1];
    };
    String.prototype.isMobile = function () {
        return (/^1[3|4|5|7|8|9][0-9]\d{4,8}$/.test(this.Trim()));
    };
    String.prototype.isTel = function () {
        //"兼容格式: 国家代码(2到3位)-区号(2到3位)-电话号码(7到8位)-分机号(3位)"
        //return (/^(([0\+]\d{2,3}-)?(0\d{2,3})-)?(\d{7,8})(-(\d{3,}))?$/.test(this.Trim()));
        return (/^(([0\+]\d{2,3}-)?(0\d{2,3})-)(\d{7,8})(-(\d{3,}))?$/.test(this.Trim()));
    };

    function chkTel() {
        var telbzb039 = $("#bzb039").val();
        if (telbzb039 == '' || telbzb039 == undefined) {
            return false;
        }
        if (telbzb039.isMobile() || telbzb039.isTel()) {
            telbzb039 = telbzb039.Trim();
            return true;
        } else {
            mini.alert("请输入正确的手机号码或电话号码\n\n例如:13916752109或0531-3614072");
            return false;
        }
    }

    //  邮箱
    function checkEmail() {
        var reg = /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/;
        // var reg = new RegExp("^[a-z0-9]+([._\\-]*[a-z0-9])*@([a-z0-9]+[-a-z0-9]*[a-z0-9]+.){1,63}[a-z0-9]+$"); //正则表达式
        var obj = $("#bzb041").val().trim();

        if (obj === "" || obj == undefined) { //输入不能为空
            return false;
        } else if (!reg.test(obj)) { //正则验证不通过，格式不对
            mini.alert("请输入正确的邮箱格式!");
            return false;
        } else {
            return true;
        }
    }

    var form = new mini.Form("#form1");

    function onSave() {
        $("#onSave").attr("disabled", true);
        form.validate();
        if (form.isValid() == false) {
            mini.alert("有必填项没有完整填写！");
            return;
        }
        var data = form.getData();

        data.bzb028q = $('input:radio:checked').val();
        if (data.bzb028q == '' || data.bzb028q == null || data.bzb028q == undefined) {
            mini.alert("请选择机构类型！");
            return;

        }

        var bzb022 = $("#bzb022").val().trim();
        if (bzb022 == '' || bzb022 == null || bzb022 == undefined) {
            mini.alert("请填写企业名称！");
            return;
        } else {
            data.bzb022 = bzb022;
        }
        var bzb030q = mini.get("bzb030q").getValue().trim();
        if (bzb030q == '' || bzb030q == null || bzb030q == undefined) {
            mini.alert("请选择企业性质！");
            return;
        } else {
            data.bzb030q = bzb030q;
            if (bzb030q == '1') {
                var bgz120 = mini.get("bgz120").getValue();
                if (bgz120 == '' || bgz120 == null || bgz120 == undefined) {
                    mini.alert("请选择母公司！");
                    return;
                } else {
                    data.bgz120 = bgz120;
                }
            } else {
                delete data.bgz120;
            }
        }
        var bzb029q = mini.get("bzb029q").getValue().trim();
        if (bzb029q == '' || bzb029q == null || bzb029q == undefined) {
            mini.alert("请选择单位性质！");
            return;
        } else {
            data.bzb029q = bzb029q;
        }
        var bzb021q = $("#bzb021q").val().trim();
        if (bzb021q == '' || bzb021q == null || bzb021q == undefined) {
            mini.alert("请填写统一社会信用代码！");
            return;
        } else {
            data.bzb021q = bzb021q;
        }

        var bzb037 = $("#bzb037").val().trim();
        if (bzb037 == '' || bzb037 == null || bzb037 == undefined) {
            mini.alert("请填写负责人！");
            return;
        } else {
            data.bzb037 = bzb037;
        }
        if (!chkTel()) {
            return;
        } else {
            var bzb039 = $("#bzb039").val().trim();
            data.bzb039 = bzb039;
        }
        if (!checkEmail()) {
            return;
        } else {
            var bzb041 = $("#bzb041").val().trim();
            data.bzb041 = bzb041;
        }
        var bzb044 = $("#bzb044").val().trim();
        if (bzb044 == '' || bzb044 == null || bzb044 == undefined) {
            mini.alert("请填写企业地址！");
            return;
        } else {
            data.bzb044 = bzb044;
        }


        var json = mini.encode(data);
        mini.confirm("您确定提交吗？", "确定？",
            function (action) {
                if (action == "ok") {
                    mini.mask({
                        el: document.body,
                        cls: 'mini-mask-loading',
                        html: '提交中...'
                    });
                    $.ajax({
                        url: '<c:url value="/register/saveRegister"/>',
                        data: data,
                        async: false,
                        type: "post",
                        success: function (data) {
                            mini.unmask(document.body);
                            if (data.code == "200") {
                                mini.alert("注册成功！正在跳转到登录页面," + data.message);
                                setTimeout(function () {
                                    login();
                                }, 5 * 1000);//延迟3000毫米
                            } else if (data.code == "300") {
                                mini.alert("注册失败" + data.message);
                                $("#onSave").attr("disabled", true);
                            } else {
                                mini.alert("注册失败！");
                            }

                        },
                        error: function (jqXHR, textStatus, errorThrown) {
                        }
                    });
                }
            }
        );
    }

    function onButtonSelect(e) {
        var btnEdit = this;
        mini.open({
            url: "<c:url value="/register/selectCompany"/>",
            title: "选择母公司",
            width: 1200,
            height: 600,
            ondestroy: function (action) {
                if (action == "ok") {
                    var iframe = this.getIFrameEl();
                    var data = iframe.contentWindow.GetData();
                    data = mini.clone(data);
                    var bgz120 = data.bgz120;
                    var bzb022 = data.bzb022;//
                    mini.get("bgz120").setValue(bgz120);
                    mini.get("bgz120").setText(bzb022); //
                }
            }
        });
    }

    function changeLx() {

        var com = document.getElementById("company");
        if (this.value == '1') {
            com.style.display = 'block';
        } else {
            com.style.display = 'none';
        }


    }

    function login() {
        document.getElementById("logout").click();
    }
</script>
</body>
</html>